package com.example.demo0

import com.example.util.p

sealed class Format2
data class Print2(val text:String): Format2()
object Newline2 : Format2()


val string2 = listOf<Format2>(Print2("Hello"),Print2("Kotlin"),Newline2,Print2("==="))

fun unsafeInterpreter(str:List<Format2>){
    str.forEach{
        when(it){
            is Print2 -> p(it.text)
            is Newline2 -> p()
        }
    }
}

fun main(){

    unsafeInterpreter(string2)

}

